<?php
  include("include/config.inc.php");
  $quantity  = 0 ;
  $tableId   = $_REQUEST['tableId'];
  $itemId    = $_REQUEST['itemId'];
  $tablePart = $_REQUEST['tablePart'];
  
  $selectQuantity = "SELECT ordereditems.quantity 
                       FROM ordereditems 
                       JOIN ordermaster  ON ordereditems.orderId = ordermaster.orderId 
                      WHERE itemId='".$itemId."' 
                        AND ordermaster.tableId = '".$tableId."'
                        AND  ordermaster.tablePart='".$tablePart."'
                        AND orderstatus = 'L'";
  $selectQuantityRes = mysql_query($selectQuantity);
  if($selectQuantityRow = mysql_fetch_array($selectQuantityRes))
  {
  	$quantity = $selectQuantityRow['quantity'];
  }
  echo $quantity;
?>